package com.itheima.service.impl;

import com.itheima.data.Customer;
import com.itheima.service.customexception.InformationNullPointer;
import com.itheima.view.BankReferenceTest;

import java.util.List;

/*
业务层
信用评估系统
 */
public class CreditAssessmentSystem {
    /**
     * 某个客户信用评估
     * @param id
     * @param list
     */
    public void findAssessCreditById(String id, List<Customer> list) {
        if (list == null) {
            return;
        }
        // Customer customer =null;
      /*  for (Customer customer1 : list) {
            if (customer1.getId().equals(id)) {
                customer = customer1;
            }*/
        //遍历集合 根据 卡号查询到该客户
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getId().equals(id) == true) {
                Customer customer = list.get(i);

                //将查询到的客户信息传递到业务层 决策支持系统
                DecisionSupportSystem decisionSupportSystem =
                        new DecisionSupportSystem();
                try {
                    decisionSupportSystem.makeLoanApprovalDecision(customer);
                } catch (InformationNullPointer e) {
                    System.out.println(e.getMessage());
                }

            }
        }



    }

    /**
     *     所有客户信用评估
     * @param list
     */

    public void findAssessCredit(List<Customer> list) {
        for (Customer customer : list) {
            System.out.println(customer.toString());
            DecisionSupportSystem decisionSupportSystem = new DecisionSupportSystem();
            try {
                decisionSupportSystem.makeLoanApprovalDecision(customer);
            } catch (InformationNullPointer e) {
                System.out.println(e.getMessage());
            }
        }
    }
}
